<template>
    <div>
        <h1>科室信息修改</h1>
        <hr>

        <table class="table">
            <tbody>
                <tr>
                    <td>编号</td>
                    <td>{{ data.DepId }}</td>
                </tr>
                <tr>
                    <td>科室名称</td>
                    <td><input type="text" v-model="data.DepName"></td>
                </tr>

                <tr>
                    <td>科室人数</td>
                    <td><input type="text" v-model="data.DepNum"></td>
                </tr>

                <tr>
                    <td>科室描述</td>
                    <td>
                        <textarea v-model="data.DepMiao">

                        </textarea>
                    </td>
                </tr>

                <tr>
                    <td>创建日期</td>
                    <td><input type="date" v-model="data.DepDate"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="修改" @click="Add"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">

import { ref ,onMounted} from 'vue';
import axios from 'axios';
import { useRoute, useRouter } from 'vue-router';

onMounted(()=>{
    Fan()
})
const route = useRoute();
const Fan = ()=>{
    var e = route.query.DepId;
    axios.get('https://localhost:7087/api/Depart/Fan',{params:{DepId:e}}).then(res=>{
        data.value = res.data;
    })
}


const router = useRouter()
const data = ref({
    "DepId": 0,
  "DepName": "",
  "DepNum": "",
  "DepMiao": "",
  "DepDate": "",
  "DepIsDelete": true
})

const Add = ()=>{
    
    axios.post('https://localhost:7087/api/Depart/DepUpd',data.value).then(res=>{
        if(res.data>0){
            alert('修改成功');
            router.push({path:"/DepShow"})
        }
        else{
            alert('修改失败')
        }
    })
}



</script>

<style scoped>

</style>